package com.org.utils.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.servlet.http.HttpServletRequest;

public class FileUtils
{
	public static String copyTemp2Normal(String tempPath,String savePath,HttpServletRequest request) throws IOException
	{
		 
		File tempFile = new File(request.getRealPath(tempPath));
		
		File normalFile = new File(request.getRealPath("/"+savePath),tempFile.getName());
		System.out.println(tempFile.getName());
		InputStream is = new FileInputStream(tempFile);
		OutputStream os = new FileOutputStream(normalFile);
		byte[] bytefer = new byte[1024];
		int length = 0;
		while ((length = is.read(bytefer)) != -1) {
			os.write(bytefer, 0, length);
		}
		os.close();
		is.close();
		return savePath+"/"+tempFile.getName();
	}
}
